/*
 * mock_server.hpp
 *
 *  Created on: 06.05.2011
 *      Author: inkooboo
 */

#ifndef _NET_MOCK_SERVER_HPP_
# define _NET_MOCK_SERVER_HPP_

# include "mock_network.hpp"

# include <boost/noncopyable.hpp>
# include <boost/shared_ptr.hpp>
# include <boost/function.hpp>
# include <boost/bind.hpp>

class tcp_server_t : boost::noncopyable
{
public:
    typedef boost::function<void(const char *, size_t)> handler_t;

    void set_data_handler(handler_t handler)
    {
        handler_ = handler;
    }

    void listen(const std::string& channel_name)
    {
        channel_ = mock_network_t::instance().get_channel(channel_name);

        channel_->on_data_.connect(handler_);
    }

    void stop_listen()
    {
        channel_.reset();
    }

private:
    boost::shared_ptr<channel_t> channel_;

    handler_t handler_;
};


#endif /* _NET_MOCK_SERVER_HPP_ */
